package com.quick.util;

import java.util.ArrayList;
import java.util.List;

import com.alibaba.fastjson2.JSONObject;
import com.fasterxml.jackson.databind.ObjectMapper;

public class Convert<T> {
	static ObjectMapper objectMapper = new ObjectMapper();
	public static   <T> List<T> convert(List<?> list, Class<T> zclass) {
		@SuppressWarnings({ "rawtypes", "unchecked" })
		List<T> result = new ArrayList();
		if(list != null ) {
			for (Object obj : list) {
				result.add(convert(obj,zclass));
			}
		}
		return result;
	}


	public static <T> T convert(Object original, Class<T> target){
		String res = JSONUtil.toStr(original);
		return JSONObject.parseObject(res, target);
	}
	
	public static <T> T convert(String original, Class<T> target){
		return JSONObject.parseObject(original, target);
	}
}
